--==============================================
--Author Panny
--date   2009/3/28
--Dec   select all city in the region of the agents 
--===============================================
CREATE PROCEDURE dbo.Pro_Orders_Pan_InsertNew
	@UserID				varchar(20),
    @AgentID			varchar(20),
    @TicketDate			datetime,
    @StartStation		nvarchar(30),
    @EndStation			nvarchar(30),
    @TrainNumber		varchar(50),
    @UserName			nvarchar(50),
    @UserTelphone		varchar(20),
    @Remark				varchar(200),
    @Pew				varchar(20),
    @UnitPrice			DECIMAL,
    @TotalMoney			DECIMAL,
    @PayMoney			DECIMAL,
    @PayPoundage		DECIMAL,
    @Amount				INT,
    @isCHD				BIT 
AS
BEGIN
	declare @OrderNumber varchar(20);
    SET @OrderNumber = dbo.fn_GetOrderNumber()
	BEGIN TRAN
    	INSERT INTO TT_Orders(
        	OrderNum,UserID,AgentID,TicketDate,
            StartStation,EndStation,TrainNumber,
            UserName,UserTelphone,Remark,Pew,
            UnitPrice,PayPoundage,TotalMoney,PayMoney,
            OrderState,Amount,IsCHD
        )
        VALUES(
        	@OrderNumber,@UserID,@AgentID,@TicketDate,
        	@StartStation,@EndStation,@TrainNumber,
            @UserName,@UserTelphone,@Remark,@Pew,
            @UnitPrice,@PayPoundage,@TotalMoney,@PayMoney,
            1,@Amount,@isCHD
        )
    COMMIT TRAN
    
END